//
//  KYCalendarCell.m
//  KuaiyanCalendar
//
//  Created by 罗新 on 2017/10/17.
//  Copyright © 2017年 KuaiYan  Co.,LTD. All rights reserved.
//

#import "KYCalendarCell.h"
#import "UIView+KY.h"
#import "KYCalendarCellItem.h"

@implementation KYCalendarCell
- (instancetype)initWithFrame:(CGRect)frame {
    if ([super initWithFrame:frame]) {
        UILabel *dayLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 30, 18)];
        dayLabel.textAlignment = NSTextAlignmentCenter;
        dayLabel.font = [UIFont boldSystemFontOfSize:14];
        dayLabel.textColor = [UIColor brownColor];
        [self addSubview:dayLabel];
        _dayLabel = dayLabel;
        UIImageView *signInImageView = [[UIImageView alloc] initWithFrame:CGRectMake(15,18,25,25)];
        [self addSubview:signInImageView];
        _signInImageView = signInImageView;
        self.layer.borderWidth = 0.25;
        self.layer.borderColor = [UIColor lightGrayColor].CGColor;
    }
    return self;
}

+ (instancetype)calendarCellWithItem:(KYCalendarCellItem *)item{
    KYCalendarCell *cell = [[KYCalendarCell alloc] init];
    [cell refreshDataWithItem:item];
    return cell;
}

- (instancetype)refreshDataWithItem:(KYCalendarCellItem *)item{
    self.dayLabel.text = [NSString stringWithFormat:@"%ld",item.day];
    switch (item.iconType) {
        case CoinDisable:
            self.signInImageView.image = [UIImage ky_imageNamed:@"checkIn_icon_lihe_nam"];
            break;
        case CoinEnable:
            self.signInImageView.image = [UIImage ky_imageNamed:@"checkIn_icon_lihe_act"];
            break;
        case TreasureBoxDisable:
            self.signInImageView.image = [UIImage ky_imageNamed:@"checkIn_box_normal"];
            break;
        case TreasureBoxEnable:
            self.signInImageView.image = [UIImage ky_imageNamed:@"checkIn_box_selected"];
            break;
        default:
            break;
    }
    if (item.highLight) {
        self.backgroundColor = [UIColor whiteColor];
    }else{
        self.backgroundColor = [UIColor colorWithRed:253/255. green:242/255. blue:231/255. alpha:1];
    }
    return self;
}

@end
